
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_agent_customer]') AND parent_object_id = OBJECT_ID(N'[dbo].[agent]'))
ALTER TABLE [dbo].[agent] DROP CONSTRAINT [FK_agent_customer]
GO


/****** Object:  Table [dbo].[agent]  ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[agent]') AND type in (N'U'))
DROP TABLE [dbo].[agent]
GO


/****** Object:  Table [dbo].[agent]  ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[agent](
	[agentId] [int] IDENTITY(1,1) NOT NULL,
	[customerId] [nchar](10) NOT NULL,
	[companyName] [nchar](50) NULL,
	[discountRate] [float] NULL,
 CONSTRAINT [PK_agent] PRIMARY KEY CLUSTERED 
(
	[agentId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[agent]  WITH CHECK ADD  CONSTRAINT [FK_agent_customer] FOREIGN KEY([customerId])
REFERENCES [dbo].[customer] ([customerId])
GO

ALTER TABLE [dbo].[agent] CHECK CONSTRAINT [FK_agent_customer]
GO

